#ifndef _DATA_CACHE_H_
#define _DATA_CACHE_H_

#include <assert.h>
#include <stdint.h>
class DataCache 
{
public:
    DataCache(int capacity);
    DataCache();
    ~DataCache();

    DataCache(DataCache& other) = delete;
    DataCache& operator=(DataCache& other) = delete;

    DataCache(DataCache&& other);
    DataCache& operator=(DataCache&& other);

    const char* operator()() const;
    char* operator()();

    const char operator[](int index) const;
    char& operator[](int index);

    inline void reset() 
    {
        assert(m_capacity > 0);
        
        if(m_data) delete[] m_data;
        m_data = new char[m_capacity]; 
    }

    inline void reset(int capacity)
    {
        assert(capacity > 0);

        if (m_data) delete[] m_data;

        m_data_size = 0;
        m_capacity = capacity;
        m_data = new char[m_capacity];
    }

    inline void set(int size) { m_data_size = size; }
    inline bool empty() { return 0 == m_data_size; }
    inline int size() { return m_data_size; }
    inline int capacity() { return m_capacity; }

private:
    char*           m_data;

    int             m_capacity;
    int             m_data_size;
public:
    uint32_t        m_in_index =0;  //进程内需要，分析转发时间
};


#endif